package com.yxm.springbootsecurity.dao;

import com.yxm.springbootsecurity.entity.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author CC11001100
 * @date 2017/10/7 3:25
 * @email CC11001100@qq.com
 */
@Repository
public class UserDao {

    @Autowired
    private JdbcTemplate mysql;

    public List<UserEntity> find(String username, String password){
        String sql = "SELECT id,username,password FROM t_user WHERE username='" + username + "' and password='" + password + "'";
        return mysql.query(sql,new BeanPropertyRowMapper(UserEntity.class));
    }

    public List<UserEntity> find(String account){
        String sql = "SELECT user_id,email,name,account,accountNo FROM user WHERE account='" + account + "'";
        return mysql.query(sql,new BeanPropertyRowMapper(UserEntity.class));
    }
    public List<UserEntity> security(String account){
        String sql = "SELECT user_id,email,name,account,accountNo FROM user WHERE accoun='" + account + "'";
        return mysql.query(sql,new BeanPropertyRowMapper(UserEntity.class));
    }
}
